package main

import (
	"errors"
	"fmt"
)

// Author : CSR丶WARRIOR
// Time ： 2020/10/20  22:51
// TOOLS : GoLand
// FILENAME : errors.go
// STATEMENT: error接口

func main() {
	res, err := divide(2, 0)
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println(res)
	}
}

func divide(num1 int, num2 int) (float64, error) {
	var err error
	if num2 == 0 {
		err = errors.New("除数不能为0")
	}
	result := float64(num1) / float64(num2)
	return result, err
}
